
/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2015原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.aop.aspectj.annotation;

import java.lang.reflect.Method;
import java.util.List;

import org.aopalliance.aop.Advice;

import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.lang.Nullable;

/**
 * Interface for factories that can create Spring AOP Advisors from classes
 * annotated with AspectJ annotation syntax.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @since 2.0
 * @see AspectMetadata
 * @see org.aspectj.lang.reflect.AjTypeSystem
 */
/**
 *可以从类创建Spring AOP Advisors的工厂的接口
 *使用AspectJ注释语法注释。
 *
 *@作者Rod Johnson
 *@作者Juergen Hoeller
 *@自2.0起
 *@参见AspectMetadata
 *@参见org.aspectj.lang.reflect.AjTypeSystem
 */
public interface AspectJAdvisorFactory {

	/**
	 * Determine whether the given class is an aspect, as reported
	 * by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}.
	 * <p>Will simply return {@code false} if the supposed aspect is
	 * invalid (such as an extension of a concrete aspect class).
	 * Will return true for some aspects that Spring AOP cannot process,
	 * such as those with unsupported instantiation models.
	 * Use the {@link #validate} method to handle these cases if necessary.
	 * @param clazz the supposed annotation-style AspectJ class
	 * @return whether this class is recognized by AspectJ as an aspect class
	 */
	/**
	 *确定给定类是否为所报告的方面
	 *通过AspectJ的｛@link org.AspectJ.lang.reflect.AjTypeSystem｝。
	 *＜p＞如果假设的方面是
	 *无效（例如具体方面类的扩展）。
	 *对于Spring AOP无法处理的某些方面，
	 *例如具有不支持的实例化模型的那些。
	 *如果需要，请使用｛@link#validate｝方法来处理这些情况。
	 *@param clazz假定的注释样式AspectJ类
	 *@return这个类是否被AspectJ识别为方面类
	 */
	boolean isAspect(Class<?> clazz);

	/**
	 * Is the given class a valid AspectJ aspect class?
	 * @param aspectClass the supposed AspectJ annotation-style class to validate
	 * @throws AopConfigException if the class is an invalid aspect
	 * (which can never be legal)
	 * @throws NotAnAtAspectException if the class is not an aspect at all
	 * (which may or may not be legal, depending on the context)
	 */
	/**
	 *给定的类是有效的AspectJ方面类吗？
	 *@param aspectClass要验证的假定AspectJ注释样式类
	 *如果类是无效方面，@throws AopConfigException
	 *（这永远都不合法）
	 *如果类根本不是方面，@throws NotAnAtAspectException
	 *（可能合法，也可能不合法，具体取决于上下文）
	 */
	void validate(Class<?> aspectClass) throws AopConfigException;

	/**
	 * Build Spring AOP Advisors for all annotated At-AspectJ methods
	 * on the specified aspect instance.
	 * @param aspectInstanceFactory the aspect instance factory
	 * (not the aspect instance itself in order to avoid eager instantiation)
	 * @return a list of advisors for this class
	 */
	/**
	 *为所有带注释的AtAspectJ方法构建Spring AOP Advisors
	 *在指定的方面实例上。
	 *@param aspectInstanceFactory方面实例工厂
	 *（不是方面实例本身，以避免急于实例化）
	 *@返回该课程的顾问列表
	 */
	List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory aspectInstanceFactory);

	/**
	 * Build a Spring AOP Advisor for the given AspectJ advice method.
	 * @param candidateAdviceMethod the candidate advice method
	 * @param aspectInstanceFactory the aspect instance factory
	 * @param declarationOrder the declaration order within the aspect
	 * @param aspectName the name of the aspect
	 * @return {@code null} if the method is not an AspectJ advice method
	 * or if it is a pointcut that will be used by other advice but will not
	 * create a Spring advice in its own right
	 */
	/**
	 *为给定的AspectJ建议方法构建一个Spring AOP Advisor。
	 *@param candidateAdviceMethod候选建议方法
	 *@param aspectInstanceFactory方面实例工厂
	 *@param declarationOrder方面内的声明顺序
	 *@param aspectName方面的名称
	 *如果方法不是AspectJ建议方法，则@return｛@code null｝
	 *或者如果它是一个切入点，将被其他建议使用，但不会
	 *自行创建Spring建议
	 */
	@Nullable
	Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
			int declarationOrder, String aspectName);

	/**
	 * Build a Spring AOP Advice for the given AspectJ advice method.
	 * @param candidateAdviceMethod the candidate advice method
	 * @param expressionPointcut the AspectJ expression pointcut
	 * @param aspectInstanceFactory the aspect instance factory
	 * @param declarationOrder the declaration order within the aspect
	 * @param aspectName the name of the aspect
	 * @return {@code null} if the method is not an AspectJ advice method
	 * or if it is a pointcut that will be used by other advice but will not
	 * create a Spring advice in its own right
	 * @see org.springframework.aop.aspectj.AspectJAroundAdvice
	 * @see org.springframework.aop.aspectj.AspectJMethodBeforeAdvice
	 * @see org.springframework.aop.aspectj.AspectJAfterAdvice
	 * @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
	 * @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
	 */
	/**
	 *为给定的AspectJ建议方法构建一个SpringAOP建议。
	 *@param candidateAdviceMethod候选建议方法
	 *@param expressionPointcut AspectJ表达式切入点
	 *@param aspectInstanceFactory方面实例工厂
	 *@param declarationOrder方面内的声明顺序
	 *@param aspectName方面的名称
	 *如果方法不是AspectJ建议方法，则@return｛@code null｝
	 *或者如果它是一个切入点，将被其他建议使用，但不会
	 *自行创建Spring建议
	 *@see org.springframework.aop.aspx检查JAroundAdvice
	 *@请参见org.springframework.aop.aectj.AspectJMethodBeforeAdvice
	 *@请参见org.springframework.aop.aspx检查JAfterAdvice
	 *@请参见org.springframework.aop.aspx检查JAfter恢复建议
	 *@请参见org.springframework.aop.aectj.AspectJAfterThrowingAdvice
	 */
	@Nullable
	Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
			MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName);

}
